﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CRM.Database.Model.Customers>" %>

<script type="text/javascript" language="javascript">

    var selectedIDs;
    function OnBeginCallback(s, e) {
        e.customArgs["selectedIDs"] = selectedIDs;
    }
    function OnSelectionChanged(s, e) {
        if (e.isSelected) {
            //  alert(s.GetRowKey(e.visibleIndex));
            var obj = gdEquipment.GetEditor("CustomEquipment");
            //obj.SetKeyValue(s.GetRowKey(e.visibleIndex));
            dde.SetKeyValue(s.GetRowKey(e.visibleIndex));
            // obj.SetText(s.GetRowKey(e.visibleIndex));
            s.GetSelectedFieldValues("Model", GetSelectedFieldValuesCallback);

            //            dde.SetKeyValue('123 - VALUE'); 
            //            dde.SetText('ASD - TEXT');

        }
    }
    function GetSelectedFieldValuesCallback(values) {
        selectedIDs = "";
        for (var index = 0; index < values.length; index++) {
            selectedIDs += values[index] + ",";
        }
        if (selectedIDs.length > 0)
            selectedIDs = selectedIDs.substring(0, selectedIDs.length - 1);


        // alert(values[0]);
        var obj = gdEquipment.GetEditor("CustomEquipment");
        obj.SetText(values[0]);
        // $("#selectedID").val(selectedIDs);

    }
    function OnSubmitClick(s, e) {
        $("#selectedIDsHF").val(selectedIDs);
    }


    //    function OnBeginCallBack(s, e) {
    //        alert("selected");
    //        e.customArgs["selectedKeys"] = 1;
    //    }


</script>

<%--<% Html.Hidden("selectedID"); %>--%>

<table >
   <tr>
    <th><%:CRM.Resourses.Resourses.customerEquipment%></th>
    <td><% Html.RenderAction("GetEquipment_Equipment_Edit", "Customers", Model); %></td><td></td>
   </tr>
</table>